home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / jmstring.zip / JMSTRING.DOC < prev    next >
Text File  |  1993-01-04  |  3KB  |  80 lines

  1.    JMString - A supplemental string unit for Turbo Pascal
  2.                  02-SEP-89 John G. Morony
  3.  
  4.                Written in Turbo Pascal v5.0
  5.  
  6.  
  7. JMString is a very tiny unit that implements some handy string
  8. functions.  There are only four routines (hey I said it was tiny
  9. didn't I ?) in the unit, but they can be of great value by
  10. relieving some grunt work for you.  The documentation that
  11. follows is not great, but source code is included to help
  12. you better understand what each function does.  Everything here
  13. is released to the public domain, use as it as you wish.  You can
  14. send questions, compliments or complaints to me via CompuServe
  15. (76220,3452) or Prodigy (MRMD03A).  
  16.  
  17. Packing List for JMSTRING.ZIP
  18.    JMSTRING.DOC  - the file you're reading now.
  19.    JMSTRING.TPU  - Turbo Pascal v5.0 compiled unit
  20.    JMSTRING.PAS  - Turbo Pascal v5.0 source code for the unit
  21.    JMDEMO.PAS    - demonstration program source code
  22.    JMDEMO.EXE    - a truly unexciting demo of the functions in
  23.                    the JMSTRING unit.  It does, however, give you
  24.                    an excellent idea of what each function in the
  25.                    unit does.
  26.  
  27. Brief descriptions:
  28.  
  29. function compact (s:string):string ;
  30.  
  31.    'Compact' will remove multiple, contiguous spaces from 's'
  32. leaving at most, one space. For example:
  33.  
  34. "    The       Quick            Brown F ox    jumped over the"
  35.  
  36. gets compacted to:
  37.  
  38. " The Quick Brown F ox jumped over the"
  39.  
  40.  
  41. function toUpper (s:string):string ;
  42.  
  43.    'toUpper' converts all alphabetic characters in 's' to their
  44. uppercase form. 
  45.  
  46.  
  47. function toLower (s:string):string ;
  48.  
  49.    'toLower' converts all alphabetic characters in 's' to their
  50. lowercase form.
  51.  
  52.  
  53. function isType (s:string; c:charSet):boolean ;
  54.  
  55. * charSet is defined as a set of char 
  56.  
  57.     'isType' returns 'TRUE' if all characters of 's' are in the
  58. set 'c'.   Thus you can check to see if a string is numeric by
  59. using the following code fragment
  60.   
  61.      if   isType('1 - 2 buckle my shoe',numerics)
  62.      then writeln ('The string contains only numbers') 
  63.      else writeln ('The string does not contain only numbers') ; 
  64.   
  65. * There are five predefined sets :
  66.  
  67.    UpperAlphas - 'A'..'Z' 
  68.    LowerAlphas - 'a'..'z'
  69.    Alphas      - UpperAlphas + LowerAlphas
  70.    Numerics    - '0'..'9'
  71.    Reals       - numerics + radixPoint  ( or period ".")
  72.                                            
  73. You could define your own set and use isType to determine if all
  74. characters in the input are members of your set.
  75.  
  76.  
  77. You are more than welcome to modify/optimize/lobotmize my code as
  78. you wish, however, if you redistribute modified code, I ask that
  79. you include the original version as well. 
  80.